package com.dt76.smallloanbackendservice.service.lhuaw.impl;

import com.dt76.smallloanbackendservice.mapper.lhuaw.ArticleManagementMapper;
import com.dt76.smallloanbackendservice.pojo.lhuaw.ArticleManagement;
import com.dt76.smallloanbackendservice.service.lhuaw.ArticleManagementService;
import com.dt76.smallloanbackendservice.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleManagementServiceImpl implements ArticleManagementService {

    @Autowired
    private ArticleManagementMapper articleManagementMapper;
    @Override
    public List<ArticleManagement> qryAllArticle() {
        System.out.println(articleManagementMapper.qryAllArticle());
        return articleManagementMapper.qryAllArticle();
    }

    @Override
    public Page qryAllArticleAll(int pageIndex, String articleTitle, String classification) {
        Page page = new Page();
        page.setPageIndex(pageIndex);
        page.setTotalCount(articleManagementMapper.qryAllArticleCount(articleTitle, classification));
        List<ArticleManagement> articleManagementList = articleManagementMapper.qryAllArticleAll((page.getPageIndex() - 1) * page.getPageSize(),
                page.getPageSize(), articleTitle, classification);
        System.out.println(articleManagementList);
        page.setRows(articleManagementList);
        return page;
    }

    @Override
    public void delArticle(int articleId) {
        articleManagementMapper.delArticle(articleId);
    }
}
